<?php  

/**
* 
*/
class Logger
{
  const LEVEL_ERROR=1;
  const LEVEL_WARNING = 2;
  const LEVEL_NOTICE = 3;
  const LEVEL_DEBUG = 4;
  
  protected $_level=4;
  
  public function setLevel($level){
    if($level >= Logger::LEVEL_ERROR && $level <= Logger::LEVEL_DEBUG && $level != $this->_level){
      $this->_level = $level;
    }
  }
  
  private function __construct($level = 4)
  {
    
  }
  
  protected static $_loggers = array();
  public static function getLogger($name=''){
    if($name==''){
      $name = '______default_____';
    }
    
    if(!isset(self::$_loggers[$name])){
      self::$_loggers[$name] = new Logger();
    }
    
    return self::$_loggers[$name];
  }
  
  public function log($message, $level=4){
    if($level>=$this->_level){
      echo '<pre>'.$message.'</pre>';
    }
  }
  
  public function dump($var, $level=4){
    $this->log(var_export($var, true), $level);
  }
}


?>